# coding:utf-8
import json


class JsonDemo:
    def _test_loads(self):
        """
        jd = JsonDemo()
        jd._test_loads()
        """
        data = '{"class":"sh_python2"}'
        dict_data = json.loads(data)
        print(type(dict_data))

    def _test_dumps(self):
        """
        jd = JsonDemo()
        jd._test_dumps()
        """
        data = '{"class":"sh_python2"}'
        dict_data = json.loads(data)
        str_data = json.dumps(dict_data)
        print(type(str_data))

    def _test_dump(self):
        """
        jd = JsonDemo()
        jd._test_dump()
        """
        data = '{"class":"sh_python2"}'
        dict_data = json.loads(data)
        f = open('./ext/cJson/json.txt', 'w')
        json.dump(dict_data, f)
        f.close()

    def _test_load(self):
        """
        jd = JsonDemo()
        jd._test_load()
        """
        f = open('./ext/cJson/json.txt', 'r')
        data = json.load(f)
        print(data)
        print(type(data))


if __name__ == '__main__':
    jd = JsonDemo()
    jd._test_load()
